import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
import thunkMiddleware from 'redux-thunk';

import Intercept_reducer from '@component/Intercept/store/reducer';
import router_reducer from './router/store/reducer';
import { receiveWebsocketReducer } from '@component/Websocket/reducer';
import Login_reducer from './pages/Home/store/reducer';
import { themeReducer } from './layout/theme';
import routerConfig_reducer from '@pages/RouteConfig/store/reducer';
import roleConfig_reducer from '@pages/RoleConfig/store/reducer';
import accountConfig_reducer from '@pages/AccountConfig/store/reducer';

import menuConfig_reducer from '@pages/MyBoss/MyMenu/store/reducer'
import order_reducer from '@pages/MyBoss/MyOrder/store/reducer'
import myClientOrder_reducer from '@pages/MyClientMenu/store/reducer'
//个人中心相关数据
import personalCenter_reducer from '@pages/PersonalCenter/store/reducer'
import getAllBoardDatas_recuer from '@pages/MyBoss/DatStatistics/store/reducer'
const win = window;
const middlewares = [thunkMiddleware];

if (process.env.NODE_ENV === 'development') {
    middlewares.push(require('redux-logger').createLogger())
}

const storeEnhancers = compose(
    applyMiddleware(...middlewares),
    (win && win.__REDUX_DEVTOOLS_EXTENSION__) ? win.__REDUX_DEVTOOLS_EXTENSION__() : (f) => f,
);


const reducers = combineReducers({
    websockets: receiveWebsocketReducer,
    Intercept: Intercept_reducer,
    router: router_reducer,
    login: Login_reducer,
    theme: themeReducer,
    routerConfig: routerConfig_reducer,
    roleConfig: roleConfig_reducer,
    accountConfig: accountConfig_reducer,
    menuConfig:menuConfig_reducer,
    orderConfig:order_reducer,
    personalCenterConfig: personalCenter_reducer,
    myClientOrderConfing:myClientOrder_reducer,
     //看板相关数据
    getAllBoardDatas: getAllBoardDatas_recuer
})

const initState = {
    websockets: {
        websocketData: {}
    },
    Intercept: {
        visible: true,
        isValidation: true
    },
    router: {
        routerData: [
            // ...store_routes
        ]
    },
    theme: {
        value: 'light'
    },
    routerConfig: {
        data: []
    },
    login: {
        isLogin: JSON.parse(sessionStorage.getItem('islogin')) ||false,
        validateString: "abcd", // 默认验证码
        userType: 'admin'
    },
    accountConfig:{
        data:[],
        role:[]
    },
    roleConfig: {
        data: [],
        bindData:[]
    },
    personalCenterConfig: {
        personalCenter: []
    },
    //看板相关数据
    getAllBoardDatas: {
        ordersInRecentSevenDays:[],
        menuList:[]
    },
     //订单信息存储
    orderConfig:{
        orderLists:[]
    },
    //菜单信息存储
    menuConfig:{
        getAllMenu:[],
        qrcode: [],
        out_trade_no: [],
        queryStatus: {}
    } 
}

export default createStore(reducers, initState, storeEnhancers);